/* 确保所有容器默认都是黑色背景 */
html, body {
  margin: 0;
  background: black;
  position: relative;
  width: 100vw;
  height: 100vh;
  overflow: hidden;
}

#container {
  position: absolute;
  top: 0; /* 移除顶部间距，让webview紧贴toolbar */
  left: 2px;
  right: 2px;
  bottom: 2px;
  background: black;
}

/* 可拖拽边框 */
.resize-border {
  position: absolute;
  background: #2c2723;
  z-index: 1000;
}

/* 上下边框 */
.resize-border.top, .resize-border.bottom {
  left: 0;
  width: 100%;
  height: 2px;
  cursor: ns-resize;
}
.resize-border.top { top: 0; }
.resize-border.bottom { bottom: 0; }

/* 左右边框 */
.resize-border.left, .resize-border.right {
  top: 0;
  width: 2px;
  height: 100%;
  cursor: ew-resize;
}
.resize-border.left { left: 0; }
.resize-border.right { right: 0; }

/* 四个角 */
.resize-corner {
  position: absolute;
  width: 6px;
  height: 6px;
  background: transparent;
  z-index: 1000;
}
.resize-corner.top-left {
  top: 0;
  left: 0;
  cursor: nw-resize;
}
.resize-corner.top-right {
  top: 0;
  right: 0;
  cursor: ne-resize;
}
.resize-corner.bottom-left {
  bottom: 0;
  left: 0;
  cursor: sw-resize;
}
.resize-corner.bottom-right {
  bottom: 0;
  right: 0;
  cursor: se-resize;
}

/* 首先定义自定义字体 */
@font-face {
  font-family: 'MyCustomFont';
  src: url('assets/game/myFont.woff2') format('woff2');
  font-weight: normal;
  font-style: normal;
}

body {
  height: 100vh;
  margin: 0;
  padding: 0;
  overflow: hidden;
  background: transparent;
  font-family: 'MyCustomFont', sans-serif; /* 添加字体应用 */
}

/* 不可拖动的区域 */
.toolbar, 
.window-controls,
button,
input {
  -webkit-app-region: no-drag;
}

/* 修改标题栏样式 */
.titlebar {
  height: 30px;
  background: #2196F3;
  display: flex;
  align-items: center;
  padding: 0 5px;
  -webkit-app-region: drag;
  color: white;
}

.titlebar-title {
  margin-right: 10px;
}

/* 修改工具栏样式 */
.toolbar {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  position: fixed;
  top: 0; /* 改为顶部固定 */
  left: 0;
  right: 0;
  height: auto;
  min-height: 30px;
  background: url('assets/底条.png') no-repeat;
  background-size: 100% 100%;
  border: none;
  -webkit-app-region: drag;
  flex-wrap: wrap;
  z-index: 1000; /* 确保工具栏在最上层 */
}

/* 修改标签区域容器 */
.tab-area {
  display: flex;
  flex-grow: 1;
  overflow-y: auto;
  height: 100%;
  align-items: flex-start;
  scrollbar-width: none;
  -ms-overflow-style: none;
  width: 90%;
  margin: 0 auto;
  flex-wrap: nowrap; /* 改为nowrap */
  flex-direction: column; /* 改为纵向排列 */
}

.tab-area::-webkit-scrollbar {
  display: none;
}

/* 修改标签栏容器样式 */
#tab-bar {
  display: flex;
  min-height: 100%;
  align-items: flex-start;
  -webkit-app-region: drag;
  flex-wrap: wrap;
  padding: 0 3px;
  width: 100%;
  gap: 2px; /* 添加间距 */
}

/* 确保标签和按钮不可拖拽 */
.tab,
.new-tab-button,
.side-button {
  -webkit-app-region: no-drag;
}

/* 修改标签样式 */
.tab {
  flex-shrink: 0;
  padding: 0 10px; /* 减小padding */
  background: url('assets/tab_normal.png') no-repeat;
  background-size: 100% 100%;
  border: none;
  margin: 0 3px;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center; /* 改为居中对齐 */
  height: 30px;
  width: 146px; /* 固定宽度 */
  min-width: 146px;
  color: #eae9e4;
  position: relative;
  font-weight: bold;
  box-sizing: border-box; /* 添加这行确保padding计入总宽度 */
}

/* 活动标签样式 */
.tab.active {
  background: url('assets/tab_select.png') no-repeat;
  background-size: 100% 100%;
  color: #43201a; /* 选中状态的文字颜色 */
}

/* 移除悬停效果的背景色变化 */
.tab:hover {
  background: url('assets/tab_select.png') no-repeat;
  background-size: 100% 100%;
}

/* 标签文本容器 */
.tab-title {
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  text-align: center; /* 文本居中 */
  font-weight: bold;
  padding-right: 20px; /* 为关闭按钮留出空间 */
}

/* 标签关闭按钮 */
.tab-close {
  position: absolute;
  right: 5px;
  top: 50%;
  transform: translateY(-50%);
  width: 20px;
  height: 20px;
  background: transparent;
  border: none;
  padding: 0;
  cursor: pointer;
  color: transparent;
  opacity: 0;
}

/* 移除关闭按钮的所有视觉效果但保持可点击 */
.tab-close:hover,
.tab-close:focus,
.tab-close:active {
  background: transparent;
  outline: none;
  border: none;
}

/* 可选：添加以下样式来调试点击区域 */
/*.tab-close {
  background: rgba(255, 0, 0, 0.2);  调试时取消注释以显示点击区域
}*/

/* 新标签按钮样式调整 */
.new-tab-button {
  height: 30px;
  width: 64px;
  border: none;
  background: url('assets/多开.png') no-repeat;
  background-size: 100% 100%;
  cursor: pointer;
  padding: 0;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
  -webkit-app-region: no-drag;
  color: transparent;
  font-family: 'MyCustomFont', sans-serif;
}

/* 移除之前的伪元素和悬停效果 */
.new-tab-button::before {
  content: none;
}

.new-tab-button:hover {
  opacity: 0.9;
}

/* 菜单按钮样式 */
.menu-toggle {
  width: 30px;
  height: 30px;
  border: none;
  background: url('assets/btn_menu.png') no-repeat;
  background-size: 100% 100%;
  cursor: pointer;
  padding: 0;
  display: flex;
  align-items: center;
  justify-content: center;
  margin: 0;
  -webkit-app-region: no-drag;
  color: transparent;
}

/* 移除原有的悬停效果 */
.menu-toggle:hover {
  background: url('assets/btn_menu.png') no-repeat;
  background-size: 100% 100%;
  opacity: 0.9; /* 可选：添加轻微的悬停效果 */
}

/* 右侧功能按钮容器 */
.side-controls {
  position: fixed;
  top: 33px; /* 调整位置到工具栏下方 */
  right: 10px;
  display: flex;
  flex-direction: column;
  gap: 5px;
  z-index: 1000;
  transition: transform 0.3s ease;
}

/* 隐藏菜单时的样式 */
.side-controls.hidden {
  transform: translateX(calc(100% + 20px)); /* 完全隐藏，包括2px的右边距 */
}

/* 功能按钮样式 */
.side-button {
  padding: 0;
  background: transparent;
  color: transparent;
  border: none;
  cursor: pointer;
  white-space: nowrap;
  display: flex;
  align-items: center;
  justify-content: center;
  width: 140px;
  height: 29px;
  background-size: 100% 100%;
  background-repeat: no-repeat;
  margin: 0;
  flex-shrink: 0;
}

/* 为每个按钮设置对应的背景图片 */
.side-button[onclick="closeWindow()"] {
  background-image: url('assets/menu_退出游戏.png');
}

.side-button[onclick="openGameWebsite()"] {
  background-image: url('assets/menu_游戏官网.png');
}

.side-button[onclick="reload()"] {
  background-image: url('assets/menu_重新加载.png');
}

.side-button[onclick="clearCache()"] {
  background-image: url('assets/menu_清除缓存.png');
}

.side-button[onclick="minimizeWindow()"] {
  background-image: url('assets/menu_最小化.png');
}

.side-button:hover {
  opacity: 0.9;
}

/* 窗口控制按钮容器 */
.window-controls {
  display: flex;
  align-items: center;
  margin-left: auto;
  height: 100%;
}

.window-control-button {
  width: 45px;
  height: 30px;
  border: none;
  background: transparent;
  cursor: pointer;
  position: relative;
  color: transparent; /* 隐藏文字 */
}

/* 最小化按钮 */
.window-control-button:nth-child(1)::before {
  content: '';
  position: absolute;
  top: 50%;
  left: 50%;
  transform: translate(-50%, -50%);
  width: 10px;
  height: 1px;
  background: #fff;
}

/* 最大化按钮 */
.window-control-button:nth-child(2)::before {
  content: '';
  position: absolute;
  top: 50%;
  left: 50%;
  transform: translate(-50%, -50%);
  width: 10px;
  height: 10px;
  border: 1px solid #fff;
}

/* 关闭按钮 */
.window-control-button:nth-child(3)::before,
.window-control-button:nth-child(3)::after {
  content: '';
  position: absolute;
  top: 50%;
  left: 50%;
  width: 12px;
  height: 1px;
  background: #fff;
}

.window-control-button:nth-child(3)::before {
  transform: translate(-50%, -50%) rotate(45deg);
}

.window-control-button:nth-child(3)::after {
  transform: translate(-50%, -50%) rotate(-45deg);
}

/* 悬停效果 */
.window-control-button:hover {
  background: rgba(255,255,255,0.1);
}

.window-control-button:nth-child(3):hover {
  background: #e81123;
}

/* 调整webview容器高度，使其动态适应工具栏高度 */
#tab-container {
  width: 100%;
  height: calc(100vh - var(--toolbar-height, 30px));
  margin-top: var(--toolbar-height, 30px); /* 添加顶部边距，为工具栏留出空间 */
  position: relative;
  background: transparent;
}

/* 修改webview样式 */
webview {
  width: 100%;
  height: 100%;
  border: none;
  position: absolute;
  top: 0;
  left: 0;
  right: 0;
  bottom: 0;
  display: none;
  background: white;
}

webview[active] {
  display: block;
}

/* 单标签模式 */
#tab-container.switch-mode webview {
  display: none;
  position: absolute;
  top: 0;
  left: 0;
  right: 0;
  bottom: 0;
}

#tab-container.switch-mode webview[active] {
  display: block;
}

/* 分屏模式 */
#tab-container.split-mode {
  overflow-y: auto;
}

#tab-container.split-mode webview {
  min-height: 300px;
  border-bottom: 1px solid #ccc;
  flex: 1;
}

/* 工具栏右侧控制按钮容器 */
.toolbar-controls {
  display: flex;
  align-items: flex-start;
  -webkit-app-region: no-drag;
  align-self: flex-start;
  height: 30px;
  padding-top: 0;
}

/* 确保所有按钮不可拖动 */
.new-tab-button,
.menu-toggle,
.tab,
.tab-close,
.side-button,
.toolbar-controls {
  -webkit-app-region: no-drag;
}

/* 确保所有文本元素都使用这个字体 */
.tab,
.new-tab-button,
.side-button,
.menu-toggle,
.toolbar,
.side-controls {
  font-family: 'MyCustomFont', sans-serif;
}